package com.yang.moyu.meta.cms.controller;

import com.yang.moyu.meta.cms.params.CmsArticleParam;
import com.yang.moyu.meta.cms.params.QryArticleListParam;
import com.yang.moyu.meta.cms.service.CmsArticleService;
import com.yang.moyu.meta.common.util.ApiResult;
import com.yang.moyu.meta.framework.aop.annotation.Log;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * Create by 10296 on 2021/12/30
 *
 * @Description: 文章管理类
 */
@RestController
@RequestMapping("/cmsArticleApi")
@Api(value = "文章管理API", tags = {"文章管理API"})
public class CmsArticleController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private CmsArticleService cmsArticleService;


    @Log("添加文章")
    @PostMapping("/addArticle")
    @ApiOperation(value = "添加文章", notes = "添加文章")
    public ApiResult addArticle(@Validated @RequestBody CmsArticleParam articleParam, HttpServletResponse response) {
        logger.info(">>>>>>>>>>>>>添加文章请求参数>>>>>>>>>>>loginParam:{}", articleParam);


        return cmsArticleService.addCmsArticle(articleParam);
    }

    @Log("查询文章列表")
    @PostMapping("/qryCmsArticleList")
    @ApiOperation(value = "添加文章", notes = "添加文章")
    public ApiResult qryCmsArticleList(@Validated @RequestBody QryArticleListParam articleParam, HttpServletResponse response) {
        logger.info(">>>>>>>>>>>>>添加文章请求参数>>>>>>>>>>>loginParam:{}", articleParam);


        return cmsArticleService.qryCmsArticleList(articleParam);
    }


}
